package com.lagou.request;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class BServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 从request域中取出数据
        String hanbao = (String) req.getAttribute("hanbao");
        System.out.println(hanbao);

        System.out.println("BServlet中功能下执行了");
//
//        // 请求转发到BServlet String path: 写的是要跳转的资源路径
//        req.getRequestDispatcher()

/*      servletContext主要作用
        1、域对象
        2、获取资源在服务器的真实地址
        3、获取全局的配置参数
        4、获取文件MIME类型

        获取ServletContext对象
        1、通过request对象获得
            ServletContext sc = request.getServletContext();
        2、继承HttpServlet后，可以直接使用
            ServletContext servletContext = this.getServletContext();
        */
    }
}
